import com.sun.media.sound.SoftTuning;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Shirly on 2016/11/15.
 */
public class test {
    public static void main(String[] args) throws IOException {
        // 直接从字符串中输入 HTML 文档
//        String html = "<html><head><title>开源中国社区</title></head>"
//                + "<body><p>这里是 jsoup 项目的相关文章</p></body></html>";
//        Document doc = Jsoup.parse(html);

// 从URL直接加载 HTML 文档
//        Document doc = Jsoup.connect("http://www.oschina.net/").get();
//        String title = doc.title();

        Document doc = Jsoup.connect("http://www.oschina.net/")
                .data("query", "Java")   //请求参数
                .userAgent("I’m jsoup") //设置User-Agent
                .cookie("auth", "token") //设置cookie
                .timeout(3000)           //设置连接超时时间
                .post();                 //使用POST方法访问URL

// 从文件中加载 HTML 文档
//        File input = new File("D:/test.html");
//        Document doc = Jsoup.parse(input,"UTF-8","http://www.oschina.net/");

        ExpressionParser expressionParser = new SpelExpressionParser();
        Expression ex  = expressionParser.parseExpression("'hello'");
        System.out.println(ex.getValue());
        StandardEvaluationContext context = new StandardEvaluationContext();
        List list = new ArrayList();
        list.add("1");
        list.add("2");
        list.add("3");
        Map map  = new HashMap();
        map.put("1","1");
        map.put("B","2");
        map.put("C","3");
        context.setVariable("list",list);
        context.setVariable("map",map);
        String a = expressionParser.parseExpression("#list[0]").getValue(context,String.class);
        System.out.println(a);
        String b = expressionParser.parseExpression("#list[1]").getValue(context,String.class);
        System.out.println(b);
        String c = expressionParser.parseExpression("#map['1']").getValue(context,String.class);
        System.out.println(c);
        System.out.println(expressionParser.parseExpression("T(java.util.Date)").getValue(Class.class));
        System.out.println(Integer.parseInt("08"));


    }


}
